{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>等级分润</h5>
        </div>
        <div class="ibox-content">
            <!--搜索框开始-->           
            <div class="row">
                <div class="col-sm-12">
                    <div  class="col-sm-2" style="width: 100px">
                        <div class="input-group" >
                            <a href="{:url('add')}"><button class="btn btn-outline btn-primary" type="button">添加规则</button></a>
                        </div>
                    </div>
                    <div class="col-sm-10">
                    <form method="post" action="{:url('index')}" id="searchForm" class="form-inline">
                        <label for="">我的等级</label>
                        {:getEnumSelectWidget(config("enum.commissionRuleLevel"), 'first_level', '-请选择我的等级-', isset($first_level) ? $first_level : '-999', 1)}
                        <label for="">上家的等级</label>
                        {:getEnumSelectWidget(config("enum.commissionRuleLevel"), 'second_level', '-请选择上家的等级-', isset($second_level) ? $second_level : '-999', 1)}
                        <label for="">上上家的等级</label>
                        {:getEnumSelectWidget(config("enum.commissionRuleLevel"), 'third_level', '-请选择上上家的等级-', isset($third_level) ? $third_level : '-999', 1)}
                        <button class="btn btn-success btn-sm" type="submit" style="margin-bottom:0;margin-left:4px"><i class="fa fa-filter"></i> 筛选</button>
                        <a class="btn btn-primary btn-sm"  style="margin-bottom:0" href="{:url('index')}"><i class="fa fa-filter"></i> 重置</a>
                    </form>
                    </div>
                </div>
            </div>
            <!--搜索框结束-->
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="table table-bordered table-hover">
                        <thead>
                            <tr class="long-tr">
                                <th>
                                    <div>我</div>
                                    <div>比例</div>
                                </th>
                                <th>
                                    <div>上家</div>
                                    <div>比例</div>
                                </th>
                                <th>
                                    <div>上上家</div>
                                    <div>比例</div>
                                </th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody id="list-content">
                            {foreach $list as $vo}
                                <tr class="long-td">
                                    <td>
                                        <div>{:getEnumString(config('enum.commissionRuleLevel'), $vo.first_level)}</div>
                                        <div>{$vo.first_rate}</div>
                                    </td>
                                    <td>
                                        {if $vo.second_level == 0}
                                            <div>--</div>
                                            <div>--</div>
                                        {else /}
                                            <div>{:getEnumString(config('enum.commissionRuleLevel'), $vo.second_level)}</div>
                                            <div>{$vo.second_rate}</div>
                                        {/if}
                                    </td>
                                    <td>
                                        {if $vo.third_level == 0}
                                            <div>--</div>
                                            <div>--</div>
                                        {else /}
                                            <div>{:getEnumString(config('enum.commissionRuleLevel'), $vo.third_level)}</div>
                                            <div>{$vo.third_rate}</div>
                                        {/if}
                                    </td>
                                    <td>{$vo.create_time}</td>
                                    <td>
                                        <a href="{:url('edit',['id'=>$vo['id']])}" class="btn btn-primary btn-xs">
                                            <i class="fa fa-edit"></i> 编辑</a>&nbsp;&nbsp;
                                        <a href="javascript:;" onclick="remove('{$vo.id}')" class="btn btn-danger btn-xs">
                                            <i class="fa fa-trash-o"></i> 删除</a>
                                    </td>
                                </tr>
                            {/foreach}
                        </tbody>
                    </table>
                    <div id="laypage">
                        {$list->render()}
                    </div>
                </div>
            </div>
            <!-- End Example Pagination -->
        </div>
    </div>
</div>
<!-- End Panel Other -->
</div>

{include file="public/footer" /}
<script type="text/javascript" src="/static/admin/js/laypage.js"></script>
<script type="text/javascript">
layui.use(['laypage', 'layer'], function(){
  var laypage = layui.laypage
  ,layer = layui.layer;

  //完整功能
  laypage.render({
    elem: 'laypage'
    ,count: '{$list->total()}' // 总数据条数
    ,curr: '{$list->currentPage()}' // 当前第几页
    ,limit: '{$list->listRows()}'   // 每页显示条数
    ,layout: ['count', 'prev', 'page', 'next', 'refresh', 'skip']
    ,jump: function(obj, first){
      //首次不执行
      if(!first){
            $("#searchForm").attr('action', '{:url("index")}?page='+obj.curr);
          $("#searchForm").submit();
      }
    }
  });
});

/*用户-删除*/
function remove(id) {
	layer.confirm('确认要删除吗？', {icon: 3}, function(index){
        window.location.href="{:url('delete')}?id="+id
	});
}
</script>

</body>
</html>